import { Modal } from 'antd';
import React, { memo,Component } from 'react'
import { withRouter } from "react-router-dom";
import './index.css'
const { confirm } = Modal;
class TurnBack extends Component{
    constructor(props) {
        super(props);
        this.state = {
            
        }
    }
    componentDidMount(){

    }
    goBack=(url,notice)=>{
        if(notice){
            confirm({
                content:notice,
                cancelText:'不返回',
                okText:'直接返回',
                onOk:()=>{
                    this.props.history.replace(url)
                },
                onCancel:()=>{}
            })
        }
        else
        this.props.history.replace(url)
    }
    render(){
        return (
            <div style={{
                display:'flex',
                justifyContent:'flex-end',
                paddingRight:'12vw'
            }}>
                <div className='turnBack' onClick={this.goBack.bind(this,this.props.url,this.props.notice)}>
                    返回上一页
                </div>
            </div>
          )
    }
}
export default withRouter(TurnBack)
